<?php
include_once("../include/init.php");
include_once("../include/base.php");
$sql = "select * from tk_new_category";
$re = mysql_query($sql);
$info=[];
if(mysql_num_rows($re)>0){
		while ($arr = mysql_fetch_assoc($re)) {
		$info[] = $arr;
	}
}
$sql = "select * from tk_new";
//搜索
$res = mysql_query($sql);
	//分页
	$totalRows= mysql_num_rows($res);
	$pageRows = 1;
	$totalpage= ceil($totalRows / $pageRows);
	$page = isset($_GET['page'])?$_GET['page']:1;
	if($page <= 0 ||$page >$totalpage ||!is_numeric($page)){
		$page = 1;
	}
	$limitStart =$pageRows *($page -1);
	$sql = "select * from tk_new  limit {$limitStart},{$pageRows}";
	$resu = mysql_query($sql);
	$list=[];
if(mysql_num_rows($res)>0){
		while ($arr = mysql_fetch_assoc($resu)) {
		$list[] = $arr;
	}
}
?>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title><?php echo $cfg_title;?></title>
		<meta name="description" content="<?php echo $cfg_description;?>"/>
		<meta name="keywords" content="<?php echo $cfg_keywords;?>"/>
		<link rel="stylesheet" href="../public/css/index.css"/>
		<link rel="stylesheet" href="../public/css/new.css"/>			
	</head>
	<body>
		<!-- 头部-->
<?php
include_once("header.php");
?>
		<!-- 主体-->

		<div class="content">
			<div class="content_top">
				<ul>			
					<?php foreach($info as $vo){?>
					<li><a href=""><?= $vo['cate_name']?></a></li>
					<?php }?>
				</ul>
			</div>
				<hr>
	<div class="clearfix"></div>
				<?php foreach ($list as $vo){?>
				<div class="new">
					<div class="new_top">
						<h3><?=$vo['title'] ?></h3>
						<span><?=date("Y-m-d H:i:s",$vo['ntime'])?></span>
						<span><?=$vo['author']?></span>		
					</div>
					<div class="img">
						<img src="<?=$vo['titleimg']?>" alt="">
					</div>
					<div class="new_content">
						<?=$vo['content']?>
					</div>					
				</div>
				<?php }?>
			<div class="pagelistbox">
					<span>共<?php echo $totalpage;?>页/<?php echo $totalRows;?>条记录 </span>
					<span class='indexPage'><a href="?page=1">首页 </a>
					<a class='prevPage' href='?page=<?php echo $page-1?>'>上页</a> 
					</span>
					<?php for($i=1;$i<=$totalpage;$i++):?>
						<?php if($i == $page):?>
							<strong><?php echo $i;?></strong>
							<?php else:?>
							<a href='?page=<?php echo $i;?>'><?php echo $i;?></a>
						<?php endif;?>
					<?php endfor;?>
					<a class='nextPage' href='?page=<?php echo $page+1;?>'>下页</a> 
					<a class='endPage' href='?page=<?php echo $totalpage;?>'>末页</a> 
			</div>
		</div>
			<hr>
		<div class="clearfix"></div>
			<!-- 页脚-->
			<?php
             include_once("footer.php");
             ?>		
	</body>
</html>
